<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="槽状态">
              <j-dict-select-tag placeholder="请选择槽状态" v-model="queryParam.status" dictCode="data_slot_status"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
               <a-button @click="handleAdd" type="primary" icon="plus" style="margin-left: 8px">新增</a-button> 
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div> 

    <!-- table区域-begin -->
    <div>  
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading" 
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <data-slot-modal ref="modalForm" @ok="modalFormOk"></data-slot-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import DataSlotModal from './modules/DataSlotModal'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'DataSlotList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      DataSlotModal
    },
    data () {
      return {
        /* 排序参数 */
        isorter:{
          column: 'slotId',
          order: 'desc',
        },
        description: '电解槽管理页面',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'槽号',
            align:"center",
            dataIndex: 'slotId'
          },
          {
            title:'所属车间',
            align:"center",
            dataIndex: 'workshopId_dictText'
          },
          {
            title:'所属工区',
            align:"center",
            dataIndex: 'areaId_dictText'
          },
          {
            title:'槽状态',
            align:"center",
            dataIndex: 'status_dictText'
          },
          {
            title:'槽类型',
            align:"center",
            dataIndex: 'typeId_dictText'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/dataSlot/dataSlot/list",
          delete: "/dataSlot/dataSlot/delete",
          deleteBatch: "/dataSlot/dataSlot/deleteBatch",
          exportXlsUrl: "/dataSlot/dataSlot/exportXls",
          importExcelUrl: "dataSlot/dataSlot/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'slotId',text:'槽号',dictCode:''})
        fieldList.push({type:'int',value:'workshopId',text:'所属车间ID',dictCode:"data_workshop,workshop_name,workshop_id"})
        fieldList.push({type:'int',value:'areaId',text:'所属工区ID',dictCode:"data_area,area_name,area_id"})
        fieldList.push({type:'int',value:'groupId',text:'语音id',dictCode:''})
        fieldList.push({type:'int',value:'status',text:'槽状态 0:停槽 1:正常槽2焙烧',dictCode:'data_slot_status'})
        fieldList.push({type:'date',value:'startDate',text:'起槽日期'})
        fieldList.push({type:'int',value:'port',text:'端口号',dictCode:''})
        fieldList.push({type:'string',value:'netboxIp',text:'槽IP',dictCode:''})
        fieldList.push({type:'string',value:'age',text:'槽龄',dictCode:''})
        fieldList.push({type:'int',value:'typeId',text:'槽类型 空 不区分 1 frist槽 2 非frist槽 3 综合利用槽',dictCode:'data_slot_type_id'})
        fieldList.push({type:'string',value:'netboxChannelId',text:'通道号',dictCode:''})
        fieldList.push({type:'int',value:'netboxSlotId',text:'转换器中对应槽号',dictCode:''})
        fieldList.push({type:'int',value:'netboxId',text:'转换器id',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>